import request from "../request";

/**
 * 查询岗位列表
 * @param {* 查询参数} params 
 * @returns json格式数据
 */
export const getPostList = async (params) => {
    return await request.get(`/api/postManagement/find`, {
        params: params
    })
}
/**
 * 删除岗位（选择）
 * @param {* 岗位编号集合} ids 
 * @returns json格式数据
 */
export const deletePostIds = async (ids) => {
    return await request.delete('/api/postManagement/delete', {
        headers: { 'Content-Type': 'application/json' },
        data: ids
    })
}
/**
 * 新增岗位
 * @param {* 岗位} posts 
 * @returns json数据格式
 */
export const insertPost = async (posts) => {
    return await request.post('/api/postManagement/insert', posts, {
        headers: { 'Content-Type': 'application/json' }
    })
}
/**
 * 更新岗位
 * @param { * 岗位} posts 
 * @returns json数据格式
 */
export const updatePost = async (posts) => {
    return await request.put('/api/postManagement/update', posts, {
        headers: { 'Content-Type': 'application/json' }
    })
}
// ---------------------------------------------------------------------------------------

/**
 * 查询部门列表（级联）
 * @param {* 查询参数} params 
 * @returns json格式数据
 */
export const findDeptList = async (params) => {
    return await request.get(`/api/departmentManagement/find`, {
        params: params
    })
}
//查询部门是否分配用户
export const findBy_deptId = async (ids) => {
    return await request({
        url: '/api/departmentManagement/findBy_deptId',
        method: 'post',
        data: ids
    })
}
/**
 * 新增部门
 * @param {* 部门} dept 
 * @returns json数据格式
 */
export const insertDept = async (deptApp) => {
    return await request.post('/api/departmentManagement/insert', deptApp, {
        headers: { 'Content-Type': 'application/json' }
    })
}
/**
 * 更新部门
 * @param { * 部门} dept 
 * @returns json数据格式
 */
export const updateDept = async (deptsUpdate) => {
    return await request.put('/api/departmentManagement/update', deptsUpdate, {
        headers: { 'Content-Type': 'application/json' }
    })
}
/**
 * 根据id删除部门
 * @param { * 部门id} deptId 
 * @returns json数据格式
 */
export const deleteDept = async (deptId) => {
    return await request.delete(`/api/departmentManagement/delete`, { data: deptId })
}

//查询岗位是否分配用户
export const findBySys_postId = async (ids) => {
    return await request({
        url: "/api/postManagement/findBySys_postId",
        method: 'post',
        data: ids
    })
}

// ---------------------------------------------------------------------------------------

/**
 * 查询角色列表
 * @param {* 查询参数} params 
 * @returns json格式数据
 */
export const findRoleList = async (params) => {
    return await request.get(`/api/roleManagement/find`, {
        params: params
    })
}

/**
 * 新增角色
 * @param {* 角色} role 
 * @returns json数据格式
 */
export const insertRole = async (data) => {
    return await request.post('/api/roleManagement/insert', data, {
        headers: { 'Content-Type': 'application/json' }
    })
}
/**
 * 更新角色
 * @param { * 角色} role 
 * @returns json数据格式
 */
export const updateRole = async (role) => {
    return await request.put('/api/roleManagement/update', role, {
        headers: { 'Content-Type': 'application/json' }
    })
}
/**
 * 删除角色（选择）
 * @param {* 角色编号集合} ids 
 * @returns json格式数据
 */
export const deleteRoleIds = async (ids) => {
    return await request.delete('/api/roleManagement/delete', {
        headers: { 'Content-Type': 'application/json' },
        data: ids
    })
}
//修改角色状态
export const updateRoleStatus = async (data) => {
    return await request({
        url: '/api/roleManagement/updateRoleStatus',
        method: 'put',
        data: data,
        headers: { 'Content-Type': 'application/json' }
    })
}

//查询角色是否分配用户
export const findRoleAssignUsers = async (ids) => {
    return await request({
        url: '/api/roleManagement/findRoleAssignUsers',
        method: 'post',
        data: ids
    })
}

// ----------------------------------------------------------------------------------------

/**
 * 查询菜单列表
 * @param {* 查询参数} params 
 * @returns json格式数据
 */
export const findMenuList = async (params) => {
    return await request.get(`/api/menuManagement/findMenuCascade`, {
        params: params
    })
}
/**
 * 新增菜单
 * @param {* 菜单} menu 
 * @returns json数据格式
 */
export const insertMenu = async (menu) => {
    return await request.post('/api/menuManagement/insert', menu, {
        headers: { 'Content-Type': 'application/json' }
    })
}
/**
 * 更新菜单
 * @param { * 菜单} menu 
 * @returns json数据格式
 */
export const updateMenu = async (menu) => {
    return await request.put('/api/menuManagement/update', menu, {
        headers: { 'Content-Type': 'application/json' }
    })
}
/**
 * 删除菜单（选择）
 * @param {* 菜单编号} menuId 
 * @returns json格式数据
 */
export const deleteMenuId = async (menuId) => {
    return await request.delete('/api/menuManagement/delete', { params: { menuId } })
}
/**
 * 查询图标列表
 * @param {* 查询参数} params 
 * @returns json格式数据
 */
export const findIconList = async (params) => {
    return await request.get('/api/menuManagement/findIcon', {
        params: { name: params }
    })
}
//查询角色拥有哪些
export const findBySys_RoleId = async (roleId) => {
    return await request.get('/api/menuManagement/findBySys_RoleId', {
        params: { roleId }
    })
}

//--------------------------------------[客户订单（主从）]------------------------------------------

//查询客户订单
export const findTableAssociation = async (searchForm) => {
    return await request.get('/api/customerOrders/find', {
        params: searchForm
    })
}

//添加客户订单
export const insertCustomerOrders = async (customerOrders) => {
    return await request.post("/api/customerOrders/insert", customerOrders, {
        headers: { 'Content-Type': 'application/json' }
    })
}

//修改客户订单
export const updateCustomerOrders = async (customerOrders) => {
    return await request.put("/api/customerOrders/update", customerOrders, {
        headers: { 'Content-Type': 'application/json' }
    })
}

//删除客户订单
export const deleteCustomerOrders = async (ids) => {
    return await request.delete("/api/customerOrders/delete", {
        headers: { 'Content-Type': 'application/json' },
        data: ids
    })
}

//添加客户订单材料
export const insertMaterial = async (customerOrdersMaterial) => {
    return await request.post("/api/customerOrders/insertMaterial", customerOrdersMaterial, {
        headers: { 'Content-Type': 'application/json' }
    })
}

//查询客户订单需要的材料，所在的仓库，以及它的库存
export const findMaterial = async (clientOrderCode) => {
    return await request.get("/api/customerOrders/findMaterial", {
        params: { clientOrderCode }
    })
}

//查询bom材料是否存在库存
export const findInventoryById = async (code) => {
    return await request.get("/api/customerOrders/findInventoryById", {
        params: { code }
    })
}

//修改客户订单材料的需求量(包括其他列)
export const updateQuantity = async (proClientOrderItem) => {
    return await request.put("/api/customerOrders/updateQuantity", proClientOrderItem, {
        headers: { 'Content-Type': 'application/json' }
    })
}

//删除订单材料表
export const deleteMaterial = async (id) => {
    return await request.delete('/api/customerOrders/deleteMaterial', { params: { id } })
}

//-------------------------------[生产工单（主从）]-------------------------------------------
//查询工单
export const findWorkOrder = async (workOrderForm) => {
    return await request.get('/api/processTickets/find', {
        params: workOrderForm
    })
}

//添加工单
export const insertProductionOrder = async (proWorkorder) => {
    return await request.post("/api/processTickets/insert", proWorkorder, {
        headers: { 'Content-Type': 'application/json' }
    })
}

//修改工单
export const updateWorkOrder = async (proWorkorder) => {
    return await request.put("/api/processTickets/update", proWorkorder, {
        headers: { 'Content-Type': 'application/json' }
    })
}

//修改工单(状态)
export const updateWorkOrderStatus = async (proWorkorder) => {
    return await request.put("/api/processTickets/updateStatus", proWorkorder, {
        headers: { 'Content-Type': 'application/json' }
    })
}

//删除工单
export const removeWorkOrder = async (ids) => {
    return await request.delete("/api/processTickets/delete", {
        headers: { 'Content-Type': 'application/json' },
        data: ids
    })
}

//查询工单Bom组成
export const findWorkOrderBom = async (productCode, workorderId) => {
    return await request.get('/api/processTickets/findBom', {
        params: { productCode, workorderId }
    })
}

//修改工单Bom
export const updateBom = async (proWorkorderBom) => {
    return await request.put("/api/processTickets/updateBom", proWorkorderBom, {
        headers: { 'Content-Type': 'application/json' }
    })
}

